home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Games of Daze
/
Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso
/
x2ftp
/
msdos
/
libs
/
knowhow4
/
contkit.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1994-10-10
|
5KB
|
176 lines
#include "contkit.h"
#include "help.h"
ContextKit::ContextKit(char* HOT, rect STATUSPOS, int STATUSTYPE,
char** STATUSSTRINGS, int* STATUSLIST)
: Context(STATUSPOS, STATUSTYPE, STATUSSTRINGS, STATUSLIST)
{
hot = HOT;
}
/////////////////////////////
void ContextKit::exe(int )
{
int sub_action = 0; // reserv
while(1)
{
mouseShowCursor();
int res_cur = current; // reserv
list[current]->exe(sub_action); // event which can not be procecced
sub_action = 0; // with current object
if(!current) // after pressing on 0th window
{ // - proceed with 1th
shift();
showStatus(1);
continue;
}
if(global_i[0]) // if exe() sets action_type to global_i[0]
{
if(global_i[0] == AC_NEXT) // command for objkit, not for any of its components
{ // usage: menu->find can not find the given string
moveTo(list[current]->isPoint()); // in the menu->itemList
showStatus(current);
sub_action = AC_NEXT;
continue;
}
int res = current; // where to return whith ESC-like command
moveTo(list[current]->isPoint());
if(global_i[0] != AC_CANCEL)
showStatus(current);
global_num = 1;
list[current]->exe(global_i[0]); // for example: button->exe(), calls menu->exe()
if(global_i[0] == AC_REDRAW || global_i[0] == AC_RESIZE
|| global_i[0] == AC_MOVE)
{
return;
}
if(global_i[0] != AC_NEXT) // return after execution, f.e. button - menu->exe(AC_LEFT) - again return to button
{
moveTo(get(list[res]));
showStatus(current);
global_num = 1;
if(list[current]->isRet(act_ret()))
{
if(global_i[0] != AC_NULL) // if !CANCEL pressed
global_i[0] = action_type;
showStatus(used);
return;
}
}
}
if(!global_i[0])
{
if(e.what == KEYEVENT)
{
char* ch;
if(hot != NULL
&& (ch = strchr(strlwr(hot), e.keypress()))
&& (e.key < 256) && e.keypress())
{
mouseHideCursor();
list[current]->show();
moveTo(ch - hot + 1);
showStatus(current);
mouseShowCursor();
continue;
}
switch(e.key)
{
case EVENT_F1:
if(help_context)
::help(help_context);
break;
case EVENT_ALT_F3:
if(!isRet(RET_REMOVE))
continue;
global_i[0] = AC_ERASE;
showStatus(used);
return;
case EVENT_ALT_F4:
// global_i[0] = AC_ERASE;
showStatus(used);
return;
case EVENT_F2:
case EVENT_RETURN:
if(list[current]->isRet(RET_REMOVE | RET_OK
| RET_MOUSE))
{
global_i[0] = action_type;
global_num = 1;
showStatus(used);
return;
}
break;
case EVENT_TAB: mouseHideCursor(); shift();
showStatus(current); mouseShowCursor(); break;
case EVENT_F6:
case EVENT_ALT_TAB:
case EVENT_F10:
case EVENT_ESC: global_i[0] = 0;
if(current != used)
showStatus(used);
return;
default: break;
}
}
else
if(e.mouse1()) // mouse pressed
{
int n = 1;
if(!list[0]->mouse_in(e.where())) // outside
{
global_i[0] = AC_CLOSE;
showStatus(used);
return;
} // mouse pressed outside
while(n != used + 1) // where it was pressed?
{
if(list[current]->mouse_in(loc(e.where())))
{
if(res_cur == current
&& list[current]->isRet(RET_MOUSE))
{
global_i[0] = action_type;
showStatus(used);
return;
}
showStatus(current);
break;
}
mouseHideCursor();
shift();
mouseShowCursor();
n++;
}
if(n == used + 1)
{
current = 0; // if background object pressed -
if(help_context) // we check it last, and try
::help(help_context); // to show help
}
}
}
}
}
////////////////////
void ContextKit::show()
{
mouseHideCursor();
if(list[0] != 0)
list[0]->show();
for(int i = 1; i <= used; i++) // attention !!! 0 - base window
list[i]->show();
moveTo(1);
showStatus(1);
mouseShowCursor();
}
/////////////////////